package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.Privilege;
import com.pgybook.db.entity.domain.PrivilegeEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface PrivilegeMapper {
    int countByExample(PrivilegeEx example);

    int deleteByExample(PrivilegeEx example);

    @Delete({
            "delete from privilege",
            "where ID = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
            "insert into privilege (NAME, DESCRIPTION)",
            "values (#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(Privilege record);

    int insertSelective(Privilege record);

    List<Privilege> selectByExample(PrivilegeEx example);

    @Select({
            "select",
            "ID, NAME, DESCRIPTION",
            "from privilege",
            "where ID = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    Privilege selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Privilege record, @Param("example") PrivilegeEx example);

    int updateByExample(@Param("record") Privilege record, @Param("example") PrivilegeEx example);

    int updateByPrimaryKeySelective(Privilege record);

    @Update({
            "update privilege",
            "set NAME = #{name,jdbcType=VARCHAR},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR}",
            "where ID = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Privilege record);
}
